package com.lbj.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository /*注解创建对象*/
public class UserDaoImpl implements UserDao{

    /*注入JdbcTemplate*/
    @Autowired
    private JdbcTemplate jdbcTemplate;

    /*少钱的方法  lucy转账100给mary*/
    @Override
    public void reduceMoney() {
        String sql = "update account set money=money-? where username=?";
        jdbcTemplate.update(sql,100,"lucy");
    }

    /*多钱的方法  mary收到lucy转的100*/
    @Override
    public void addMoney() {
        String sql = "update account set money=money+? where username=?";
        jdbcTemplate.update(sql,100,"mary");
    }

}
